﻿using System;
using System.Collections;
using System.Data;
using CE.Database;

/// <summary>
/// Summary description for MainPageUserAccessDB
/// </summary>
/// 
namespace CE.UserAccess
{
    public class MainPageUserAccessDB
    {
        public MainPageUserAccessDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(MainPageUserAccess mainpageuseraccess)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocProviderUserAccessMainPagesInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter

            _sPara.Add("@RefCEUserId", mainpageuseraccess.RefCEUserId);
            _sPara.Add("@ProviderCompanyId", mainpageuseraccess.ProviderCompanyId);
            _sPara.Add("@MainPageId", mainpageuseraccess.MainPageId);
            _sPara.Add("@AccessLevel", mainpageuseraccess.AccessLevel);
            _sPara.Add("@Status", mainpageuseraccess.Status);

            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataTable GetMainPageAccess(Int64 ProviderCompanyId, Int64 MainPageId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable();
            string _spName = "sprocProviderUserAccessMainPagesSelectItemListByUser";
            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@ProviderCompanyId", ProviderCompanyId);
            _sPara.Add("@MainPageId", MainPageId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion
            
            _dtResult = _db.GetDataTableBySP(_spName, _sPara);
            
            return _dtResult;
        }

    }
}